﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DCSLibrary;
using Utils.DatabaseUtils;
using Utils.DC.Web.UI;
using Telerik.Web.UI;

public partial class Admin_Module_quan_tri_pool : System.Web.UI.UserControl
{
    #region Cac bien dung chung
    PoolTopicUI objPool = new PoolTopicUI();
    DataSet dsPool;
    #endregion

    #region Cac Ham Su Kien

    protected void Page_Load(object sender, EventArgs e)
    {
        dsPool = objPool.GetAll();
        //if (!IsPostBack)
        //{
        BindGrid();
        //}
    }

    protected void Pool_Delete(object sender, EventArgs e)
    {
        try
        {
            LinkButton button = (LinkButton)sender;
            int result = objPool.DeleteByID(Convert.ToInt32(button.CommandArgument));
            if (result > 0)
            {
                //Response.Write(messageBox.Alert(MessageBox.MESSAGE_ADD_SUCCESSFULLY));
                lblMessage.Text = MessageBox.MESSAGE_DELETE_SUCCESSFULLY;
                BindGrid();
            }
            else
            {
                //Response.Write(messageBox.Alert(MessageBox.MESSAGE_ADD_NOT_SUCCESSFULLY));
                lblMessage.Text = MessageBox.MESSAGE_DELETE_NOT_SUCCESSFULLY;
            }
        }
        catch (Exception ex)
        {
            lblMessage.Text = MessageBox.MESSAGE_CONFILCT_DATA;
        }
    }

    protected void Ajax_Request(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            dsPool = objPool.GetAll();
            BindGrid();
        }
    }

    #endregion

    #region Cac Ham Tuong Tac Du Lieu

    private void BindGrid()
    {
        try
        {
            grd.DataSource = dsPool.Tables[0];
            grd.DataBind();
        }
        catch (Exception e)
        {

        }
    }
    #endregion
}
